﻿/*-------------------------------------------------------------------------
* 命名空间: MyToDo.ViewModels/SettingsViewModel
* 类       名: SettingsViewModel
* 功      能:  TD
* 时      间:  2023/12/14 11:32:06
* 版      本:  V1.0
* 作      者:  Fioman
* 格      言:  Talk is cheap,show me the code ^_^
*-------------------------------------------------------------------------*/
using MyToDo.Extensions;
using MyToDo.Models;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.ObjectModel;

namespace MyToDo.ViewModels
{
    public class SettingsViewModel : BindableBase
    {

        public SettingsViewModel(IRegionManager RegionManager)
        {
            SettingsMenuBars = new ObservableCollection<MenuBar>();
            IntiSettingsMenuBars();

            NavigateCommand = new DelegateCommand<MenuBar>(DoNavigateCommand);
            _regionManager = RegionManager;
        }

        private void DoNavigateCommand(MenuBar MenuObj)
        {
            if (MenuObj != null && !string.IsNullOrWhiteSpace(MenuObj.ViewName))
            {
                _regionManager.Regions[PrismManager.SettingsViewRegion].RequestNavigate(MenuObj.ViewName);
            }
        }

        private void IntiSettingsMenuBars()
        {
            SettingsMenuBars.Add(new MenuBar() { Icon = "Palette", Title = "个性化", ViewName = "SkinView" });
            SettingsMenuBars.Add(new MenuBar() { Icon = "Cog", Title = "系统设置", ViewName = "SysConfigView" });
            SettingsMenuBars.Add(new MenuBar() { Icon = "InformationVariant", Title = "关于我们", ViewName = "AboutView" });
        }

        private ObservableCollection<MenuBar> settingsMenuBars = null!;

        public ObservableCollection<MenuBar> SettingsMenuBars
        {
            get { return settingsMenuBars; }
            set
            {
                settingsMenuBars = value;
                RaisePropertyChanged();
            }
        }

        public DelegateCommand<MenuBar> NavigateCommand { get; private set; }

        private readonly IRegionManager _regionManager;
    }
}
